﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="goodsPromotion.aspx.cs" Inherits="WebApp.admin.goods.goodsPromotion" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../css/skin.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" language="javascript">

        function openModalForm() {

            window.open('exchangeGoods.aspx?geid=' + escape(document.getElementById('hdEge').value), '_blank', 'height=400,width=600,top=50,left=100,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=no');
            }
    </script>
</head>

<script type="text/javascript" src="../js/main.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="/My97DatePicker/WdatePicker.js" charset="utf-8"></script>

<script type="text/javascript">
    $(function () {
        $("#selectPromotionType").change(function () {
            if ($("#selectPromotionType").val() == 0) {
                $("#trLimitAmount").hide();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 1) {
                $("#trLimitAmount").hide();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 2) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").show();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 3) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").show();
                $("#trGift").hide();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 4) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").show();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 5) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").show();
                $("#trIsOverlap").show();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 6) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").show();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 7) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").show();
                $("#trExchangeGoods").show();
                $("#trLinkUrl").show();
            }
        });

        $(document).ready(function () {
            if ($("#selectPromotionType").val() == 0) {
                $("#trLimitAmount").hide();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 1) {
                $("#trLimitAmount").hide();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 2) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").show();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 3) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").show();
                $("#trGift").hide();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 4) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").show();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 5) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").show();
                $("#trIsOverlap").show();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 6) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").show();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").hide();
                $("#trExchangeGoods").hide();
                $("#trLinkUrl").hide();
            }
            if ($("#selectPromotionType").val() == 7) {
                $("#trLimitAmount").show();
                $("#txtFloorAmount").show();
                $("#trDiscount").hide();
                $("#trPreferentialAmount").hide();
                $("#trGift").hide();
                $("#trPresentedIntegral").hide();
                $("#trIsOverlap").hide();
                $("#trDollarAmount").show();
                $("#trExchangeGoods").show();
                $("#trLinkUrl").show();
            }
        });
        $("#btnSubmit").click(function () {
            if ($("#txtPromotionTitle").val() == "") {
                alert("请输入活动标题！");
                $("#txtPromotionTitle").focus();
                return false;
            }
            if ($("#selectPromotionType").val() == 0) {
                alert("请选择活动类型！");
                $("#selectPromotionType").focus();
                return false;
            }
            if ($("#txtSortOrder").val() == "") {
                alert("请输入优先排序！");
                $("#txtSortOrder").focus();
                return false;
            }
            if ($("#selectPromotionType").val() == 1) {
                if ($("#txtFloorAmount").val() == "") {
                    alert("请输入下限金额！");
                    $("#txtFloorAmount").focus();
                    return false;
                }
            }
            if ($("#selectPromotionType").val() == 2) {
                if ($("#txtLimitAmount").val() == "") {
                    alert("请输入上限金额！");
                    $("#txtLimitAmount").focus();
                    return false;
                }
                if ($("#txtFloorAmount").val() == "") {
                    alert("请输入下限金额！");
                    $("#txtFloorAmount").focus();
                    return false;
                }
                if (parseFloat($("#txtFloorAmount").val()) <= parseFloat($("#txtLimitAmount").val())) {
                    alert("下限金额必须大于上限金额！");
                    $("#txtFloorAmount").focus();
                    return false;
                }
                if ($("#txtDiscount").val() == "") {
                    alert("请输入优惠百分比！");
                    $("#txtDiscount").focus();
                    return false;
                }
            }
            if ($("#selectPromotionType").val() == 3) {
                if ($("#txtLimitAmount").val() == "") {
                    alert("请输入上限金额！");
                    $("#txtLimitAmount").focus();
                    return false;
                }
                if ($("#txtFloorAmount").val() == "") {
                    alert("请输入下限金额！");
                    $("#txtFloorAmount").focus();
                    return false;
                }
                if (parseFloat($("#txtLimitAmount").val()) <= parseFloat($("#txtFloorAmount").val())) {
                    alert("下限金额必须大于上限金额！");
                    $("#txtFloorAmount").focus();
                    return false;
                }
                if ($("#txtPreferentialAmount").val() == "") {
                    alert("请输入优惠金额！");
                    $("#txtPreferentialAmount").focus();
                    return false;
                }
            }
            if ($("#selectPromotionType").val() == 4) {
                if ($("#txtLimitAmount").val() == "") {
                    alert("请输入上限金额！");
                    $("#txtLimitAmount").focus();
                    return false;
                }
                if ($("#txtFloorAmount").val() == "") {
                    alert("请输入下限金额！");
                    $("#txtFloorAmount").focus();
                    return false;
                }
                if ($("#ddlSelectGift").val() == "") {
                    alert("请选择赠送礼品！");
                    $("#ddlSelectGift").focus();
                    return false;
                }
            }
            if ($("#selectPromotionType").val() == 5 || $("#selectPromotionType").val() == 6) {
                if ($("#txtLimitAmount").val() == "") {
                    alert("请输入上限金额！");
                    $("#txtLimitAmount").focus();
                    return false;
                }
                if ($("#txtFloorAmount").val() == "") {
                    alert("请输入下限金额！");
                    $("#txtFloorAmount").focus();
                    return false;
                }
                if (parseFloat($("#txtLimitAmount").val()) <= parseFloat($("#txtFloorAmount").val())) {
                    alert("下限金额必须大于上限金额！");
                    $("#txtFloorAmount").focus();
                    return false;
                }
                if ($("#txtPresentedIntegral").val() == "") {
                    alert("请输入赠送积分！");
                    $("#txtPresentedIntegral").focus();
                    return false;
                }
            }
            if ($("#selectPromotionType").val() == 7) {
                if ($("#txtLimitAmount").val() == "") {
                    alert("请输入上限金额！");
                    $("#txtLimitAmount").focus();
                    return false;
                }
                if ($("#txtFloorAmount").val() == "") {
                    alert("请输入下限金额！");
                    $("#txtFloorAmount").focus();
                    return false;
                }
                if (parseFloat($("#txtFloorAmount").val()) <= parseFloat($("#txtLimitAmount").val())) {
                    alert("下限金额必须大于上限金额！");
                    $("#txtFloorAmount").focus();
                    return false;
                }
                if ($("#txtDollarAmount").val() == "") {
                    alert("请输入加价金额！");
                    $("#txtDollarAmount").focus();
                    return false;
                }
                if ($("#hdEge").val() == "") {
                    alert("请选择换购商品！");
                    $("#btnExchangeGoods").click();
                    return false;
                }
            }
            if ($("#txtStartTime").val() == "") {
                alert("请输入开始日期！");
                $("#txtStartTime").focus();
                return false;
            }
            if ($("#txtEndTime").val() == "") {
                alert("请输入结束日期！");
                $("#txtEndTime").focus();
                return false;
            }
            var d1 = new Date(Date.parse($("#txtStartTime").val().replace("-", "/")));
            var d2 = new Date(Date.parse($("#txtEndTime").val().replace("-", "/")));
            if (d1 > d2) {
                $("#txtEndTime").select();
                alert("结束日期不能小于开始日期！");
                return false;
            }
            return true;
        });
    });




</script>

<body class="body" onload="">
    <table class="main" cellpadding="0" cellspacing="0">
        <tr>

            <td class="td_middle_middle">
                <div class="maincontent">
                <div  class="navgater"><img src="../images/module.gif" width="20" height="22" alt=""/>
所在位置：促销活动->
<%= Request.QueryString["ot"] == "ed" ? "促销活动编辑" : "促销活动添加"%>

<a style=" display:block; float:right;" href="javascript:location.href=document.referrer;" ><img src="../images/history.gif" border="0" /></a>
</div>
                    <form name="form1" id="form1" runat="server">

                        <table cellpadding="0" cellspacing="0" style="width: 100%">
                            <tr>
                                <td class="td_title">
                                    活动标题：</td>
                                <td class="td_content">
                                    <input name="txtPromotionTitle" runat="server" type="text" id="txtPromotionTitle" maxlength="50" />*最多50个字符</td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    活动类型：</td>
                                <td class="td_content">
                                    <select name="selectPromotionType" runat="server" id="selectPromotionType">
	                                    <option value="0">请选择活动类型...</option>
	                                    <option value="1">订单满额免运费</option>
	                                    <option value="2">订单满额打折</option>
	                                    <option value="3">订单满额减少</option>
	                                    <option value="4">订单满额赠送礼品</option>
	                                    <option value="5">订单满额送积分</option>
	                                    <option value="6">充值送积分</option>
	                                    <option value="7">订单满额加价换购</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    优先排序：</td>
                                <td class="td_content">
                                    <input name="txtSortOrder" runat="server" type="text" id="txtSortOrder" onkeyup="this.value=this.value.replace(/\D/g,'')" value="0" maxlength="10" />*</td>
                            </tr>
                            <tr id="trLimitAmount" style="display: none;">
                                <td class="td_title">
                                    上限金额：</td>
                                <td class="td_content">
                                    <input name="txtLimitAmount" runat="server" type="text" id="txtLimitAmount" onpaste="return false" style="ime-mode: disabled" onkeypress="if((event.keyCode&lt;48 || event.keyCode>57) &amp;&amp; event.keyCode!=46 || /\.\d\d$/.test(value))event.returnValue=false" />*</td>
                            </tr>
                            <tr id="trFloorAmount">
                                <td class="td_title">
                                    下限金额：</td>
                                <td class="td_content">
                                    <input name="txtFloorAmount" runat="server" type="text" id="txtFloorAmount" onpaste="return false" style="ime-mode: disabled" onkeypress="if((event.keyCode&lt;48 || event.keyCode>57) &amp;&amp; event.keyCode!=46 || /\.\d\d$/.test(value))event.returnValue=false" />*</td>
                            </tr>
                            <tr id="trDiscount" style="display: none;">
                                <td class="td_title">
                                    优惠百分比：</td>
                                <td class="td_content">
                                    <input name="txtDiscount" runat="server" type="text" id="txtDiscount" onkeyup="this.value=this.value.replace(/\D/g,'')" />%
                                    *</td>
                            </tr>
                            <tr id="trPreferentialAmount" style="display: none;">
                                <td class="td_title">
                                    优惠金额：</td>
                                <td class="td_content">
                                    <input name="txtPreferentialAmount" runat="server" type="text" id="txtPreferentialAmount" onpaste="return false" style="ime-mode: disabled" onkeypress="if((event.keyCode&lt;48 || event.keyCode>57) &amp;&amp; event.keyCode!=46 || /\.\d\d$/.test(value))event.returnValue=false" />元
                                    *</td>
                            </tr>
                            <tr id="trPresentedIntegral" style="display: none;">
                                <td class="td_title">
                                    赠送积分：</td>
                                <td class="td_content">
                                    <input name="txtPresentedIntegral" runat="server" type="text" id="txtPresentedIntegral" onkeyup="this.value=this.value.replace(/\D/g,'')" />
                                    *</td>
                            </tr>
                            <tr id="trIsOverlap" style="display: none;">
                                <td class="td_title">
                                    商品是否叠加赠送积分：</td>
                                <td class="td_content">
                                    <input value="1" name="isOverlap" runat="server" type="radio" id="rdIsOverlap1" />是&nbsp;&nbsp;
                                    <input value="0" name="isOverlap" runat="server" type="radio" id="rdIsOverlap0" />否
                                </td>
                            </tr>
                            <tr id="trGift" style="display: none;">
                                <td class="td_title">
                                    赠送礼品：</td>
                                <td class="td_content">

                                  <asp:DropDownList id="ddlSelectGift" runat="server" name="gift">
                                  
                                  
                                  </asp:DropDownList>
                                
                                </td>
                            </tr>
                            <tr id="trDollarAmount" style="display: none;">
                                <td class="td_title">
                                    加价金额：</td>
                                <td class="td_content">
                                    <input name="txtDollarAmount" runat="server" type="text" id="txtDollarAmount" onpaste="return false" style="ime-mode: disabled" onkeypress="if((event.keyCode&lt;48 || event.keyCode>57) &amp;&amp; event.keyCode!=46 || /\.\d\d$/.test(value))event.returnValue=false" />元
                                    *</td>
                            </tr>
                            <tr id="trExchangeGoods" style="display: none;">
                                <td class="td_title">
                                    换购商品：</td>
                                <td class="td_content">
                                    <input id="btnExchangeGoods" runat="server" type="button" class="formButton" value="选择商品" onclick="openModalForm();" />
                                    <input name="hdEge" runat="server" type="hidden" id="hdEge" />
                                       <input name="lblGoods" runat="server" readonly="readonly" type="text" id="lblGoods" />
      
                                    *</td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    开始日期：</td>
                                <td class="td_content">
                                    <input name="txtStartTime" runat="server" type="text" id="txtStartTime" maxlength="10" onfocus="new WdatePicker(this,'%Y-%M-%D',true,'default')" onpaste="return false" style="ime-mode: disabled" />*</td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    结束日期：</td>
                                <td class="td_content">
                                    <input name="txtEndTime" runat="server" type="text" id="txtEndTime" maxlength="10" onfocus="new WdatePicker(this,'%Y-%M-%D',true,'default')" onpaste="return false" style="ime-mode: disabled" />*</td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                 <asp:Button ID="btnSubmit" runat="server" Text="确  定" CssClass="formButton" OnClick="btnSubmit_Click"   />&nbsp;&nbsp;&nbsp;&nbsp;
                                    <input id="btnBack" type="button" class="formButton" value=" 返  回 " onclick="javascript:location.href=document.referrer;" /></td>
                            </tr>
                        </table>
                     </form>
                </div>
                </td>
        </tr>

    </table>
</body>
</html>
